package cn.bgs.controller;

import cn.bgs.common.AliOss;
import cn.bgs.pojo.Maintenance;
import cn.bgs.pojo.User;
import cn.bgs.service.IMaintenanceService;
import cn.bgs.service.IUserService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Date;
import java.util.List;

@RequestMapping("/sbaoxiu")
@RestController
public class BaoxiuController {
    @Autowired
    private IMaintenanceService iMaintenanceService;
    @Autowired
    private IUserService userService;

    @Autowired
    private AliOss aliOss;

    @RequestMapping("findAll")
    public List<Maintenance> findAll(Integer CommunityId){
        return iMaintenanceService.findAll(CommunityId);
    }

    @RequestMapping("into")
    public Boolean into(@Param("theTitle") String theTitle,@Param("problemDescription") String problemDescription,@Param("phone") Integer phone,@Param("appointmentTime") Date appointmentTime){
        return iMaintenanceService.into(theTitle,problemDescription,phone,appointmentTime);
    }
    @RequestMapping("file")
    public String file(@RequestParam("file") MultipartFile file){

        return iMaintenanceService.file(file);
    }
    @RequestMapping("intoFind")
    public List<User> intoFind(String relationShip){
        return userService.intoFind(relationShip);
    }

    @RequestMapping("delete")
    public Boolean delete(Integer maintenanceId){
        return iMaintenanceService.delete(maintenanceId);
    }

    @RequestMapping("update")
    public Boolean baoUpdate(){
        return null;
    }

    @RequestMapping("findById")
    private List<Maintenance> findById(Integer id){
        return iMaintenanceService.findById(id);
    }

    @RequestMapping("shenhe")
    private Boolean shenhe(@Param("id") Integer id,@Param("shenhe") Integer shenhe){
        return iMaintenanceService.shenhe(id,shenhe);
    }


}
